include('graphics.node');

// Generates the static background star locations based on the
// width and height of the viewport.
function generateStars(stars, width, height, num) {
  for (var i = 0; i < num; i++) {
    var x_coord = Math.floor(Math.random() * width);
    var y_coord = Math.floor(Math.random() * height);
    stars.push({x: x_coord, y: y_coord});
  }
};

new_class(
  'SpaceBackDrop',
  function() {
    graphics.Node.call(this, 0, 0);
    this.z = -1000;
    this._stars = [];
    var num_stars = 75;
    generateStars(this._stars, 10000, 10000, num_stars);
  },
  {
    draw: function(d) {
      var context = d.getContext()
      // In space, no one can hear your scream. Also, it's really dark.
      context.fillStyle = "#000";
      context.fillRect(0, 0, 1000, 1000);

      context.fillStyle = "#555555";
      for (var i = 0; i < this._stars.length; i++) {
        // TODO(stevet): Draw stars with different brightness levels.
        context.fillRect(this._stars[i].x, this._stars[i].y, 1, 1);
      }
    }
  },
  graphics.Node);
